<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script type="text/javascript" src="../js/jquery-3.6.0.min.js"></script>
<body>
    <form id="updateForm">
        <input type="hidden" th:value="${demo.demoid}" name="demoid"/>
        姓名<input type="text" th:value="${demo.demoname}" name="demoname"/>
        <input type="button" value="提交" onclick="saveBtn()"/>
    </form>
</body>
<script>

    function saveBtn(){
        $.ajax({
            url: "../demo/updateDemo",
            type: "post",
            data: $("#updateForm").serialize(),
            success:function (data){
                alert("修改成功!");
                location.href="../demo/show";
            },error:function (){
                alert("修改失败!");
            }
        })
    }

</script>
</html>